/**
 * Licensee: DuKe TeAm
 * License Type: Purchased
 */
package ormsamples;

import org.orm.*;
public class ListCineData {
	private static final int ROW_COUNT = 100;
	
public void listTestData() throws PersistentException {
		orm.DAOFactory lDAOFactory = orm.DAOFactory.getDAOFactory();
		System.out.println("Listing Pelicula...");
		orm.Pelicula[] ormPeliculas = lDAOFactory.getPeliculaDAO().listPeliculaByQuery(null, null);
		int length = Math.min(ormPeliculas.length, ROW_COUNT);
		for (int i = 0; i < length; i++) {
			System.out.println(ormPeliculas[i]);
		}
		System.out.println(length + " record(s) retrieved.");
		
		System.out.println("Listing Genero...");
		orm.Genero[] ormGeneros = lDAOFactory.getGeneroDAO().listGeneroByQuery(null, null);
		length = Math.min(ormGeneros.length, ROW_COUNT);
		for (int i = 0; i < length; i++) {
			System.out.println(ormGeneros[i]);
		}
		System.out.println(length + " record(s) retrieved.");
		
		System.out.println("Listing Clasificacion...");
		orm.Clasificacion[] ormClasificacions = lDAOFactory.getClasificacionDAO().listClasificacionByQuery(null, null);
		length = Math.min(ormClasificacions.length, ROW_COUNT);
		for (int i = 0; i < length; i++) {
			System.out.println(ormClasificacions[i]);
		}
		System.out.println(length + " record(s) retrieved.");
		
		System.out.println("Listing Sala...");
		orm.Sala[] ormSalas = lDAOFactory.getSalaDAO().listSalaByQuery(null, null);
		length = Math.min(ormSalas.length, ROW_COUNT);
		for (int i = 0; i < length; i++) {
			System.out.println(ormSalas[i]);
		}
		System.out.println(length + " record(s) retrieved.");
		
	}
	
	public void listByCriteria() throws PersistentException  {
		System.out.println("Listing Pelicula by Criteria...");
		orm.PeliculaCriteria peliculaCriteria = new orm.PeliculaCriteria();
		// Please uncomment the follow line and fill in parameter(s) 
		//peliculaCriteria.id.eq();
		peliculaCriteria.setMaxResults(ROW_COUNT);
		orm.Pelicula[] ormPeliculas = peliculaCriteria.listPelicula();
		int length =ormPeliculas== null ? 0 : Math.min(ormPeliculas.length, ROW_COUNT); 
		for (int i = 0; i < length; i++) {
			 System.out.println(ormPeliculas[i]);
		}
		System.out.println(length + " Pelicula record(s) retrieved."); 
		
		System.out.println("Listing Genero by Criteria...");
		orm.GeneroCriteria generoCriteria = new orm.GeneroCriteria();
		// Please uncomment the follow line and fill in parameter(s) 
		//generoCriteria.id.eq();
		generoCriteria.setMaxResults(ROW_COUNT);
		orm.Genero[] ormGeneros = generoCriteria.listGenero();
		length =ormGeneros== null ? 0 : Math.min(ormGeneros.length, ROW_COUNT); 
		for (int i = 0; i < length; i++) {
			 System.out.println(ormGeneros[i]);
		}
		System.out.println(length + " Genero record(s) retrieved."); 
		
		System.out.println("Listing Clasificacion by Criteria...");
		orm.ClasificacionCriteria clasificacionCriteria = new orm.ClasificacionCriteria();
		// Please uncomment the follow line and fill in parameter(s) 
		//clasificacionCriteria.id.eq();
		clasificacionCriteria.setMaxResults(ROW_COUNT);
		orm.Clasificacion[] ormClasificacions = clasificacionCriteria.listClasificacion();
		length =ormClasificacions== null ? 0 : Math.min(ormClasificacions.length, ROW_COUNT); 
		for (int i = 0; i < length; i++) {
			 System.out.println(ormClasificacions[i]);
		}
		System.out.println(length + " Clasificacion record(s) retrieved."); 
		
		System.out.println("Listing Sala by Criteria...");
		orm.SalaCriteria salaCriteria = new orm.SalaCriteria();
		// Please uncomment the follow line and fill in parameter(s) 
		//salaCriteria.id.eq();
		salaCriteria.setMaxResults(ROW_COUNT);
		orm.Sala[] ormSalas = salaCriteria.listSala();
		length =ormSalas== null ? 0 : Math.min(ormSalas.length, ROW_COUNT); 
		for (int i = 0; i < length; i++) {
			 System.out.println(ormSalas[i]);
		}
		System.out.println(length + " Sala record(s) retrieved."); 
		
	}
	
	public static void main(String[] args) {
		try {
			ListCineData listCineData = new ListCineData();
			try {
				listCineData.listTestData();
				//listCineData.listByCriteria();
			}
			finally {
				orm.CinePersistentManager.instance().disposePersistentManager();
			}
		}
		catch (Exception e) {
			e.printStackTrace();
		}
	}
}
